<template>
  <div class="AddDialog" v-if="visible">
    <el-dialog :visible="visible" width="900px" :show-close="false">
      <div slot="title">
        <p class="titleP">{{ title }}</p>
        <i class="icon el-icon-circle-close" @click="close"></i>
      </div>
      <div class="conent">
        <el-form :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
          <el-form-item label="文件名称" prop="fileName">
            <el-input v-model="ruleForm.fileName"  :placeholder="title==='新增派发'?'请输入文件名称':'某某文件'"></el-input>
          </el-form-item>
          <el-form-item label="产品名称" prop="productName">
            <el-input v-model="ruleForm.productName" :placeholder="title==='新增派发'?'请输入产品名称':'某某文件'"></el-input>
          </el-form-item>
          <el-form-item label="派发文件" prop="file">
            <el-upload
              action="https://jsonplaceholder.typicode.com/posts/"
              :file-list="ruleForm.fileList"
              accept=".doc, docx"
            >
              <el-button size="small">{{title==='新增派发'?'上传文件':'重新上传文件'}}</el-button>
              <span style="margin-left:10px" slot="tip" class="el-upload__tip">支持扩展名: doc. docx格式</span>
            </el-upload>
          </el-form-item>
          <el-form-item :label="title==='新增派发'?'文件描述':'派发描述'">
            <el-input type="textarea" v-model="ruleForm.describe"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="submit()">保存并发起审批</el-button>
        <el-button size="small" @click="call()">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'AddDialog',
  props: {
    visible: Boolean,
    title: {
      type: String,
      default: '提示'
    }
  },
  data () {
    return {
      dialogVisible: false,
      ruleForm: {
        fileName: '', // 文件名称
        productName: '', // 产品名称
        file: '', // 文件上传
        describe: '', // 文件描述
        fileList: [{ name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100' }, { name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100' }]
      },
      rules: {
        fileName: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        productName: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        file: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submit () {
    },
    close () {
      this.$emit('update:visible', false)
    }
  }
}
</script>

<style scoped lang="less">
.AddDialog {
  .titleP {
    background: #fff;
    font-size: 18px;
    height: 60px;
    line-height: 60px;
    padding: 0 30px;
    position: relative;
    margin-bottom: 10px;
    &::before {
      content: '';
      width: 4px;
      height: 16px;
      background: #5290ff;
      position: absolute;
      top: 22px;
      left: 15px;
    }
  }
  /deep/ .el-dialog__header {
    background-color: white;
    color: #303133;
    text-align: left;
    position: relative;
    // font-weight: bold;
    .icon {
      font-size: 20px;
      position: absolute;
      top: 20px;
      right: 20px;
    }
  }
  /deep/ .dialog-footer {
    margin: 0 auto;
    text-align: center;
  }
  .el-button + .el-button {
    margin-left: 200px;
  }
}
</style>
